package com.framwork.core.api.accessToken.input;

import com.alibaba.fastjson.JSONObject;
import com.framwork.core.base.AbstractAPIInput;
import okhttp3.FormBody;
import okhttp3.RequestBody;

/**
 * @author ：james.liu
 * @date ：Created in 2022/3/4 15:50
 * @description：获取 tenant_access_token（应用商店应用）
 * @version: 1.0
 */
public class OpenApisAuthV3TenantAccessTokenInput extends AbstractAPIInput {

    /**
     * 应用授权凭证
     */
    private String appAccessToken;
    /**
     * 企业标识，两种获取方式：
     */
    private String tenantKey;

    public String getAppAccessToken() {
        return appAccessToken;
    }

    public void setAppAccessToken(String appAccessToken) {
        this.appAccessToken = appAccessToken;
    }

    public String getTenantKey() {
        return tenantKey;
    }

    public void setTenantKey(String tenantKey) {
        this.tenantKey = tenantKey;
    }

    public final RequestBody toRequestBody() {
        RequestBody r = null;
        final FormBody.Builder builder = new FormBody.Builder();
        builder.add("app_access_token", this.getAppAccessToken());
        builder.add("tenant_key", this.getTenantKey());
        r = builder.build();
        return r;
    }

    public final String toBody(OpenApisAuthV3TenantAccessTokenInput input) {
        JSONObject r = new JSONObject();
        r.put("app_access_token", this.getAppAccessToken());
        r.put("tenant_key", this.getTenantKey());
        return r.toJSONString();
    }

}
